package org.mark.storage.mapper;

import org.mark.storage.entity.StorageInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface StorageInfoMapper extends BaseMapper<StorageInfo> {
    @Select("SELECT s.id AS storageId, s.name AS storageName, s.capacity, IFNULL(SUM(f.inventory), 0) AS inventory " +
            "FROM t_storage_info s " +
            "LEFT JOIN t_fresh_food f ON s.id = f.storage_id " +
            "GROUP BY s.id, s.name, s.capacity")
    List<Map<String, Object>> selectStorageInventory();
}